package com.zmn.oms.zmn.business.interfaces.open;

import com.zmn.oms.common.constant.OrderLogConsts;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.entity.work.OrderWorkLogChange;
import org.springframework.scheduling.annotation.Async;

import java.util.Date;

/**
 * 类描述：订单状态变更通知
 *
 * @author liuying
 * @date 2019/06/13 20:34
 */
public interface OrderChangeNotifyService {

    /**
     * 订单状态通知
     *
     * @param orderWorkLogChange
     */
    @Async
    void notifyChange(OrderWorkLogChange orderWorkLogChange) throws OmsBaseException;


    // 判断是否是修改预约时间
    default boolean isChangeDutyTime(int logType, OrderWorkLogChange orderWorkLogChange) {
        if (OrderLogConsts.ORDER_LOG_TYPE_UPDATE == logType
                || OrderLogConsts.ORDER_LOG_TYPE_CONFIRM == logType
                || OrderLogConsts.ORDER_LOG_TYPE_MASTER_MODIFY_DUTY_TIME == logType
                || OrderLogConsts.ORDER_LOG_TYPE_MODIFY_DUTY_TIME == logType) {
            Date dutyTime = orderWorkLogChange.getDutyTime();
            // 确认&修改操作时，不改预约时间时，dutyTime为null，
            // 所以这里dutyTime不为null，就可以判定为修改了预约时间
            return dutyTime != null;
        }
        return false;
    }

}
